package org.skyeye.modeling.policies;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.DirectEditPolicy;
import org.eclipse.gef.requests.DirectEditRequest;
import org.skyeye.modeling.commands.RenameNodeCommand;
import org.skyeye.modeling.figures.DeviceFigure;
import org.skyeye.modeling.model.MNode;


public class NodeDirectEditPolicy extends DirectEditPolicy{

	protected Command getDirectEditCommand(DirectEditRequest request) {
		 RenameNodeCommand cmd = new RenameNodeCommand();
        cmd.setNode((MNode) getHost().getModel());
        cmd.setName((String) request.getCellEditor().getValue());
        return cmd;
	}
	protected void showCurrentEditValue(DirectEditRequest request) {
		String value = (String) request.getCellEditor().getValue();
		((DeviceFigure) getHostFigure()).setName(value);
	}
}
